package com.adingxiong.useritem.service;

import com.adingxiong.pojo.User;
import com.adingxiong.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName UserServiceImpl
 * @Description TODO
 * @Author xiongchao
 * @Date 2020/7/30 14:55
 **/
@Slf4j
@Service
public class UserServiceImpl implements UserService {

    private List<User> list = new ArrayList<>();

    @PostConstruct
    public void init (){
        list.add(new User(1 ,"zhangsan0" , "123456"));
        list.add(new User(2 ,"lisi" , "123456"));
        list.add(new User(3 ,"wangwu" , "123456"));
        list.add(new User(4 ,"lihua" , "123456"));
    }

    @Override
    public User getUser(Integer integer) {
        log.info("params is {}" , integer);
        for (User vo : list){
            if(vo.getId().equals(integer)){
                return vo;
            }
        }
        return null;
    }

    @Override
    public void addScore(Integer integer, Integer integer1) {
        log.info("user "+integer+" - 增加积分 "+integer1);
    }
}
